/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author rodrigo
 */
@Entity
@Table(name = "Gabarito")
@NamedQueries({
    @NamedQuery(name = "Gabarito.findAll", query = "SELECT g FROM Gabarito g"),
    @NamedQuery(name = "Gabarito.findByGabaritoId", query = "SELECT g FROM Gabarito g WHERE g.gabaritoId = :gabaritoId"),
    @NamedQuery(name = "Gabarito.findByNota", query = "SELECT g FROM Gabarito g WHERE g.nota = :nota")})
public class Gabarito implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "gabarito_id")
    private Integer gabaritoId;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "nota")
    private Float nota;
    @JoinTable(name = "Gabarito_Alternativas", joinColumns = {
        @JoinColumn(name = "gabarito_id", referencedColumnName = "gabarito_id")}, inverseJoinColumns = {
        @JoinColumn(name = "alternativa_id", referencedColumnName = "alternativa_id")})
    @ManyToMany
    private List<Alternativa> alternativaList;
    @JoinColumn(name = "usuario_id", referencedColumnName = "usuario_id")
    @ManyToOne(optional = false)
    private Usuario usuarioId;
    @JoinColumn(name = "prova_id", referencedColumnName = "prova_id")
    @ManyToOne(optional = false)
    private Prova provaId;

    public Gabarito() {
    }

    public Gabarito(Integer gabaritoId) {
        this.gabaritoId = gabaritoId;
    }

    public Integer getGabaritoId() {
        return gabaritoId;
    }

    public void setGabaritoId(Integer gabaritoId) {
        this.gabaritoId = gabaritoId;
    }

    public Float getNota() {
        return nota;
    }

    public void setNota(Float nota) {
        this.nota = nota;
    }

    public List<Alternativa> getAlternativaList() {
        return alternativaList;
    }

    public void setAlternativaList(List<Alternativa> alternativaList) {
        this.alternativaList = alternativaList;
    }

    public Usuario getUsuarioId() {
        return usuarioId;
    }

    public void setUsuarioId(Usuario usuarioId) {
        this.usuarioId = usuarioId;
    }

    public Prova getProvaId() {
        return provaId;
    }

    public void setProvaId(Prova provaId) {
        this.provaId = provaId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (gabaritoId != null ? gabaritoId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Gabarito)) {
            return false;
        }
        Gabarito other = (Gabarito) object;
        if ((this.gabaritoId == null && other.gabaritoId != null) || (this.gabaritoId != null && !this.gabaritoId.equals(other.gabaritoId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "modelo.Gabarito[ gabaritoId=" + gabaritoId + " ]";
    }
    
}
